package com.platform.hjt.flow.service;

import java.util.List;

import javax.annotation.Resource;

import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;

import com.hjt.tools.dao.Page;
import com.hjt.tools.dao.PropertyFilter;
import com.hjt.tools.date.DateCreator;
import com.platform.hjt.base.controller.ReturnBody;
import com.platform.hjt.base.service.BaseService;
import com.platform.hjt.flow.dao.FlowFromDAO;
import com.platform.hjt.flow.model.FlowFrom;

@Service
public class FlowFromService extends BaseService{

	@Resource
	private FlowFromDAO flowFromDAO;
	
	public ReturnBody saveFlowFrom(FlowFrom flowFrom){
		if(StringUtils.isNotBlank(flowFrom.getFlowFromId())){
			flowFromDAO.updatePerproties(flowFrom);
			return  new ReturnBody(true, "更新成功");
		}else{
			flowFrom.setIsDel(false);
			flowFrom.setCreateTime(DateCreator.getCurrentTime());
			flowFromDAO.saveJ(flowFrom);
			return  new ReturnBody(true, "添加成功");
		}
	}
	
	public ReturnBody delFlowFrom(FlowFrom flowFrom){
		flowFrom.setIsDel(true);
		flowFromDAO.updatePerproties(flowFrom);
		return  new ReturnBody(true, "删除成功");
	}
	
	public Page<FlowFrom> getFlowFromList(Page<FlowFrom> page, List<PropertyFilter> propertyFilterList){
		return flowFromDAO.findPage(page, propertyFilterList);
	}
	
	public List<FlowFrom> getFlowFromList(List<PropertyFilter> filters){
		return flowFromDAO.find(filters);
	}
	
	public FlowFrom getFlowFrom(List<PropertyFilter> filters){
		return flowFromDAO.findUniqueBy(filters);
	}
	
	public FlowFrom getFlowFrom(String propertyName, Object value){
		return flowFromDAO.findUniqueBy(propertyName, value);
	}
	
}
